#include <stdio.h>

int main() {
	char str[1001], *p;
	int s, l;
	while(scanf("%s", str) == 1) {
		//printf("%s\n", str);
		p = str;
		s = 0;
		while(*p != 0) {
			l = *p - '0';
			s += l;
			p++;

		}
		if(s > 0)
			if(s % 3 == 0 && (l == 0 || l == 5))
				printf("TAK\n");
			else
				printf("NIE\n");			
	}
	return 0;
}
